<extend name="Base/common"/>
<block name="side">
    <div class="sidebar">
        <ul class="side-nav">
            <include file="menu"/>
        </ul>
    </div>
</block>
<block name="body">

    <div id="main-content">
        <div id="main" class="main" style="min-height: 380px;">
            <div class="row">
                <h1>审核记录</h1>
                <div class="admin">
                    欢迎 <span style="color: red;">{:get_nickname()}</span> 登陆系统
                </div>
                <include file="Public/dashboardbn"/>
            </div>
            <div class="search-form">
                <form id="search" action="{:U('Index/search')}" method="post" >
                    <div class="sleft">
                        <span class="search-title">经销商代码</span>
                        <input id="dealer_name" class="search-input" type="text" placeholder="" value="{:I('dealer_name','')}" name="dealer_name">
                        <span class="search-title">车牌号码</span>
                        <input id="plate_number" class="search-input" type="text" placeholder="" value="{:I('plate_number','')}" name="plate_number">

                    </div>
                    <input type="hidden" name="controller" value="{$CONTROLLER_NAME}">
                    <input type="hidden" name="action" value="{$ACTION_NAME}">
                    <button id="searchSubmit" class="btn ajax-post" target-form="ids" type="submit">搜索</button>
                    <a class="btn ajax-post" target-form="ids"  style="float: right;" href="__SELF__">刷新</a>
                </form>
            </div>
            <div class="table-responsive">
                <table class="table table-hover table-striped">
                    <thead>
                        <tr>
                            <th>NO.</th>
                            <th>查看结算单</th>
                            <th>经销商名称</th>
                            <th>提交时间</th>
                            <th>车牌号码</th>
                            <th>备件号</th>
                            <th>轮胎条数</th>
                            <th>补贴金额</th>

                            <if condition="$uid eq 3">
                                <th>审核状态</th>
                                <th style="text-align: center;">审核</th>
                                <th>原因</th>
                            </if>
                        </tr>
                    </thead>
                    <tbody>

                        <volist name="list" id="info" key="key">
                                <input style="display:none;" type="text" name="id" value="{$info.id}">
                                <tr class="record" data-id="{$key}" data-picture="{:get_file($info['statement'],'path')}">
                                    <p class="statement_picture" style="display:none;">{:get_file($info['statement'],'path')}</p>

                                    <td>{$info.id}</td>
                                    <td class="jump-img red" style="cursor:pointer;text-decoration:underline;">
                                        <volist name=":get_images($info['images'])" id="img">
                                            <a class="img" data-src="{$img.path}" style="cursor:pointer;text-decoration:underline;margin: 0 3px;">查看</a>
                                        </volist>
                                    </td>
                                    <td>{:get_nickname($info['user_id'])}</td>
                                    <td>{$info.created_at|date='Y-m-d',###}</td>
                                    <td>{$info.plate_number}</td>
                                    <td>{$info.tyre_number}</td>
                                    <td>{$info['number']*2}</td>
                                    <td>￥{$info.price}</td>

                                    <if condition="$uid eq 3">

                                        <if condition="$info.status eq 0">
                                            <td class="orange">未审核</td>
                                            <else/>
                                            <td class="green">已审核</td>
                                        </if>
                                        <td style="text-align: center;">
                                            <button class="btn" style="background: #5cb85c;border: none;vertical-align: initial;    line-height: initial;" data-action="redirect" data-src="{:U('Agent/api',['id'=>$info['id'],'action'=>'check','status'=>1])}"> 通过</button>
                                            <button class="btn" style="background: #f0ad4e;border: none;vertical-align: initial;    line-height: initial;" data-action="redirect" data-src="{:U('Agent/api',['id'=>$info['id'],'action'=>'check','status'=>2])}"> 未通过</button>
                                        </td>
                                        <td>
                                            <select name="cause" style="padding: 3px 0;    line-height: initial;">
                                                <volist name="causes" id="cause">
                                                    <option value="{$cause}">{$cause}</option>
                                                </volist>
                                            </select>
                                        </td>
                                    </if>
                                </tr>

                        </volist>
                    </tbody>
                </table>
            </div>
            <div class="page">
                <div>
                    {$_page}
                </div>
            </div>


        </div>
    </div>
    <include file="Dealer/var"/>

    <script>
        $(function(){
            $(".btn").on("click",function(){
                var $this = $(this), $action = $this.data("action"), $src = $this.data("src"),$confirm = $this.data("confirm");
                var $cause = $(this).parent('td').next('td').children("select").val();
                if ( $confirm && !confirm($confirm) ) {
                    return;
                }
                switch ($action){
                    case "redirect":
                        if ($src){
                            window.location.href = $src + "&cause="+$cause;
                        }else {
                            console.log("无src值");
                        }
                        break;
                    default:
                        console.log("无操作");
                }
            });
        });
    </script>
</block>